<template>
	<view class="root-lay">
		<view class="head-lay flex-h">
			<view class="head-title">{{headTitle}}</view>
		</view>

		<view class="content-lay flex-v">
			<view class="line">
				<picker @change="bindPickerChange" :value="pickerIndex" :range="pickerArray" range-key="urlName">
					<view class="info-picker flex-h">
						<image style="width: 20upx; height: 20upx;" src="@/static/imgs/select/sync_url.png" />

						<view style="margin: 0rpx 50rpx;flex-grow: 1;">{{pickerArray[pickerIndex].urlName}}</view>

						<image style="width: 20upx; height: 20upx;" src="@/static/imgs/login/icon_dropdown@2x.png" />
					</view>
				</picker>
			</view>

			<view class="line flex-h">
				<image style="width: 20upx; height: 20upx;" src="@/static/imgs/select/sync_user.png" />
				<input class="input-lay" v-model="userName"></input>
				<image style="width: 20upx; height: 20upx;" src="@/static/imgs/login/icon_dropdown@2x.png" />
			</view>

			<view class="line flex-h">
				<image style="width: 20upx; height: 20upx;" src="@/static/imgs/select/sync_pwd.png" />
				<input password class="input-lay" v-model="userPwd"></input>
				<image style="width: 20upx; height: 20upx;" src="@/static/imgs/login/icon_dropdown@2x.png" />
			</view>

			<view class="line flex-h" style="border: 0px">
				<button @click="onBtnClick" style="flex-grow: 1;color: #fff; background-color: #007AFF;">{{$t("functionSelect.syncLogin.loginBtn")}}</button>
			</view>

		</view>
	</view>
</template>

<script>
	import syncTextData from '@/common/sync_loginData.js'
	export default {
		data() {
			let _self = this;
			return {
				headTitle: _self.$t("functionSelect.syncLogin.title"),

				pickerArray: syncTextData.loginUrls,
				pickerIndex: 0,
				
				userName: '',
				userPwd: '',
			};
		},

		methods: {
			bindPickerChange(e) {

			},
			
			onBtnClick() {
				if(this.userName.length == 0 || this.userPwd.length == 0) {
					uni.showToast({
						title: this.$t("functionSelect.syncLogin.inputTip"),
						icon: "none",
						duration: 800
					})
					return;
				}
				
				getApp().globalData.isUnlockSync = true;					
				this.$emit("onBtnClick" ,true);
			}
		}


	}
</script>

<style lang="scss" scoped>
	.root-lay {
		position: relative;
		padding-top: var(--status-bar-height);
		width: 100%;
	}

	.head-lay {
		height: 35upx;
		position: relative;
		padding: 5upx;
		border: 1px solid rgba(0, 0, 0, 0.16);
		;
		border-left: 0rpx;
		border-right: 0rpx;

		.head-title {
			margin: 0 auto;
			font-size: 25upx;
			font-weight: bold;
			color: #333333;

		}

		.head-right {
			position: absolute;
			right: 0;
			height: 100%;
			align-items: center;

			.head-tool {
				font-size: 18upx;
				color: #333333;
				margin-right: 10upx;
			}
		}
	}

	.content-lay {
		width: 100%;
		box-sizing: border-box;
		align-items: center;
		margin: 100rpx 0rpx;

		.line {
			width: 70%;
			box-sizing: border-box;
			background: #FFFFFF;
			border-radius: 8px;
			border: 1px solid #D8D8D8;
			padding: 10rpx 15rpx;

			position: relative;
			align-items: center;

			margin-bottom: 30rpx;

			.input-lay {
				margin: 0rpx 50rpx;
				flex-grow: 1;
			}
		}

		.info-picker {
			position: relative;
			align-items: center;
		}
	}
</style>
